package com.qianyu.project.web.controller.sy;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qianyu.project.core.context.user.FlowUserManager;
import com.qianyu.project.entity.SystemUser;
import com.qianyu.project.entity.TenderCompany;
import com.qianyu.project.service.ISystemUserService;
import com.qianyu.project.service.ITenderCompanyService;
import com.qianyu.project.utils.PageUtil;
import com.qianyu.project.utils.Result;
import com.qianyu.project.utils.ResultTool;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/tenderCompany")
public class TenderCompanyController2 {

    @Autowired
    private ITenderCompanyService tenderCompanyService;

    @GetMapping
    public Result getList(@RequestParam Map<String, String> params) {
        Map<String, String> map = new HashMap<>();
        map.put("id", params.get("id"));
        map.put("company_name", params.get("companyName"));
        QueryWrapper<TenderCompany> wrapper = new QueryWrapper<>();
        wrapper.allEq(map, false);
        if(StringUtils.hasLength(params.get("companyName"))){
            wrapper.like("company_name", params.get("companyName"));
        }
        IPage page = PageUtil.createPage(params);
        IPage iPage = tenderCompanyService.page(page, wrapper);
        return ResultTool.success(iPage);
    }
}
